<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>批量打印订单</title>
    <style>
        @media print {
            .no-print { display: none; }
            .page-break { page-break-after: always; }
        }
        
        .order-print {
            width: 100%;
            margin: 20px 0;
            padding: 20px;
            border: 1px solid #ddd;
            font-family: Arial, sans-serif;
        }
        
        .order-header {
            text-align: center;
            margin-bottom: 20px;
            border-bottom: 2px solid #333;
            padding-bottom: 10px;
        }
        
        .order-info {
            display: flex;
            justify-content: space-between;
            margin-bottom: 20px;
        }
        
        .order-info div {
            flex: 1;
        }
        
        .order-table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }
        
        .order-table th,
        .order-table td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: left;
        }
        
        .order-table th {
            background-color: #f5f5f5;
            font-weight: bold;
        }
        
        .order-total {
            text-align: right;
            margin-top: 20px;
            font-size: 16px;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="no-print" style="text-align: center; margin: 20px;">
        <button onclick="window.print()" class="btn btn-primary">打印订单</button>
        <button onclick="window.close()" class="btn btn-default">关闭</button>
    </div>
    
    {volist name="list" id="order"}
    <div class="order-print {if condition="!$key_last"}page-break{/if}">
        <div class="order-header">
            <h2>订单详情</h2>
            <p>订单号：{$order.order_no}</p>
        </div>
        
        <div class="order-info">
            <div>
                <h4>订单信息</h4>
                <p>订单状态：{$order.order_status_text}</p>
                <p>支付方式：{$order.pay_type_text}</p>
                <p>下单时间：{$order.createtime|date='Y-m-d H:i:s',###}</p>
                {if condition="$order.delivery_time"}
                <p>发货时间：{$order.delivery_time|date='Y-m-d H:i:s',###}</p>
                {/if}
            </div>
            
            <div>
                <h4>用户信息</h4>
                <p>用户名：{$order.user.username|default=''}</p>
                <p>昵称：{$order.user.nickname|default=''}</p>
            </div>
            
            <div>
                <h4>收货地址</h4>
                {if condition="$order.userAddress"}
                <p>收货人：{$order.userAddress.name}</p>
                <p>联系电话：{$order.userAddress.mobile}</p>
                <p>收货地址：{$order.userAddress.address}</p>
                {/if}
            </div>
        </div>
        
        <table class="order-table">
            <thead>
                <tr>
                    <th>商品名称</th>
                    <th>规格</th>
                    <th>单价</th>
                    <th>数量</th>
                    <th>小计</th>
                </tr>
            </thead>
            <tbody>
                {volist name="order.orderItems" id="item"}
                <tr>
                    <td>{$item.product_name}</td>
                    <td>{$item.product_sku.sku_name|default='默认规格'}</td>
                    <td>￥{$item.price}</td>
                    <td>{$item.quantity}</td>
                    <td>￥{$item.total_amount}</td>
                </tr>
                {/volist}
            </tbody>
        </table>
        
        <div class="order-total">
            <p>商品总额：￥{$order.total_amount}</p>
            <p>运费：￥{$order.freight_amount}</p>
            <p>优惠金额：￥{$order.discount_amount}</p>
            <p style="font-size: 18px; color: #e74c3c;">实付金额：￥{$order.pay_amount}</p>
        </div>
        
        {if condition="$order.remark"}
        <div style="margin-top: 20px;">
            <strong>备注：</strong>{$order.remark}
        </div>
        {/if}
    </div>
    {/volist}
</body>
</html>